<template>
    <div>
      <van-tabs :active="active">
        <van-tab title="收藏店铺">
          内容1
        </van-tab>
        <van-tab title="收藏商品">
          <view class="goods-list">
            <view v-for="(item, i) in collect" :key="i" @click="gotoDetail(item)">
              <!-- 为 my-goods 组件动态绑定 goods 属性的值 -->
              <my-goods :goods="item"></my-goods>
            </view>
          </view></van-tab>
        <van-tab title="关注商品">内容 3</van-tab>
        <van-tab title="足迹">内容 4</van-tab>
      </van-tabs>
    </div>
    

</template>

<script>
  export default {
    // setup() {
    //     const active = ref(0);
    //     return { active };
    //   },
    data() {
      return {
        active:1,
        collect:[],
        
        // 请求参数对象
            queryObj: {
              // 查询关键词
              query: '',
              // 商品分类Id
              cid: '',
              // 页码值
              pagenum: 1,
              // 每页显示多少条数据
              pagesize: 10
            },
            // 商品列表的数据
              goodsList: [],
                // 总数量，用来实现分页
              total: 0,
            defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png',
            
            // 是否正在请求数据
                isloading: false
      }
    },
    onShow:function(){
      // 获取页面对象
      const pages = getCurrentPages();
      this.$data.active = pages[1].options.type-1
      // console.log(pages[1].options.type);
      // 读取缓存中的数据
      const collect = wx.getStorageSync("collect")||[]
      this.$data.collect = collect
    },
    methods: {
      gotoDetail(item){
        uni.navigateTo({
          url: '/subpkg/goods_detail/goods_detail?goods_id=' + item.goods_id
        })
      }
    }
  }
</script>

<style lang="scss">
.goods-item {
  display: flex;
  padding: 10px 5px;
  border-bottom: 1px solid #f0f0f0;

  .goods-item-left {
    margin-right: 5px;

    .goods-pic {
      width: 100px;
      height: 100px;
      display: block;
    }
  }

  .goods-item-right {
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .goods-name {
      font-size: 13px;
    }

    .goods-price {
      font-size: 16px;
      color: #c00000;
    }
  }
}
</style>
